home *** CD-ROM | disk | FTP | other *** search
- Path: news2.ios.com!usenet
- From: vlad@gramercy.ios.com (Vlastimil Adamovsky)
- Newsgroups: comp.lang.c++
- Subject: Re: class for accessing indiv bits
- Date: Mon, 18 Mar 1996 03:52:19 GMT
- Organization: Internet Online Services
- Message-ID: <4iim8k$ime@news2.ios.com>
- References: <4h3396$l4f@oclc.org>
- NNTP-Posting-Host: ppp-54.ts-7.hck.idt.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- razin@oclc.org (Irina Razin) wrote:
-
- >I was thinking about writing a class for simulating array
- >of bits, where each member of that array can serve as a
- >binary variable, so for example, by allocating just two
- >long integers I would have an array of sizeof(long)*8
- >elements.
-
- >Having such a class would be a lot of fun. Anybody have it
- >implemented already? I have written basic functions for
- >retrieving, setting and toggling bits, but they are very
- >C-style. How about overloaded [],=, copy constructors etc
- >so it looks just like a regular data type?
-
- It is very easy to implement.
- Just use a fact that byte has 8 bits, and then use bitwise logical
- operators like & and |.
- Also, you will need to use the % C language operator. That's it.
- Having those facts in your hands, go ahead and create a subclass of a
- vector of characters (bytes) and redefine and define some functions.
-
-
-
- *******************************************
- * Vlastimil Adamovsky *
- * Smalltalk, C++ and Envelop development *
- *******************************************
-
-